{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">订单管理</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"
               data-auth-add="{:$auth->check('order.order/add')}"
               data-auth-edit="{:$auth->check('order.order/edit')}"
               data-auth-delete="{:$auth->check('order.order/del')}"
        ></table>
    </div>
</div>
<script type="text/html" id="picTpl">
    <img style="max-width:80px; max-height:30px;" src="{{d.avatarUrl}}" data-image="{{d.nickname}}">
</script>
<!--status 1待支付 2待发货 3待收货 4已完成 5已评价 6售后退货 7已取消  pay_status 0未支付 1已支付 2已退款 is_tui 0未退 1已退-->
<script type="text/html" id="barTool">
    <a data-open='{:url("jf_list")}?order_id={{ d.order_id }}'
       class="layui-btn layui-btn-xs {:$auth->check('orderjf/jf_list')?'':'layui-hide'}"
       title="积分列表">积分列表</a>

    {{# if(d.status==2){ }}
    <a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("send")}?id={{ d.id }}' data-title="发货"
       data-full="true">发货</a>
    {{# } }}

    {{# if(d.status==3){ }}
    <a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("send")}?id={{ d.id }}' data-title="修改发货"
       data-full="true">修改发货</a>
    {{# } }}

    {{# if(d.status==4||d.status==5||d.status==6){ }}
    <a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("sendMsg")}?id={{ d.id }}' data-title="发货信息"
       data-full="true">发货信息</a>
    {{# } }}

    {{# if((d.status==2||d.status==3||d.status==4||d.status==5)&&d.is_tui==0){ }}
    <a data-open='{:url("refund")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs layui-btn-danger {:$auth->check('order.order/refund')?'':'layui-hide'}"
       title="查看订单">后台退款</a>
    {{# } }}

<!--    {{# if((d.status==2||d.status==7)&&(d.pay_type==2||d.pay_type==3||d.pay_type==5)){ }}-->
<!--            <a href="javascript:;" onclick="wk.confirm('{{d.id}}','{:url('refund2')}','确定后台退款吗？')"-->
<!--           class="layui-btn layui-btn-danger layui-btn-xs {:$auth->check('order.order/edit')?'':'layui-hide'}" title="后台退款">后台退款2</a>-->
<!--    {{# } }}-->
</script>


<!--操作模板-->

{/block}
{block name="script"}
<script>
    var selectElement = null;
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: "{:url('add')}",
            edit_url: "{:url('edit')}",
            delete_url: "{:url('del')}",
        };
        var proviec = {:json_encode($proviec)};
        table.render({
            init: init,
            autoWidth: true,
            toolbar: ['refresh',],
            url: '{:url("index")}',
            cols: [
                [
                    //预约时间 是否分派 陪诊服务 陪诊人员 会员折扣 优惠卷金额
                    // {type: 'checkbox', fixed: 'left'},
                    {field: 'id', width: '4%', title: 'ID',search:false},
                    {field: 'order_no', align: "center", width: '18%', title: '订单编号'},

                    {field: 'nickname', align: "center", width: '10%', title: '下单会员'},
                    {field: 'mobile', align: "center", width: '10%', title: '会员电话',search:false},
                    {field: 'avatarUrl', align: "center", width: '10%', title: '用户头像', templet: '#picTpl',search:false},
                    //0未完成 1已完成
                    {
                        field: 'status', align: "center", width: '10%', title: '订单状态', templet: function (d) {
                            if (d.status == 1) {
                                return '<span style="color: black">领取完成</span>';
                            } else {
                                return '<span style="color: #2A57FE">领取中</span>';
                            }
                        }, selectList: {0:'领取中',1:'领取完成'}
                    },
                    {field: 'create_time', align: "center", width: '15%', title: '创建时间', search: 'range'},

                    {field: 'sum_jf', align: "center", width: '10%', title: '总积分',search:false},
                    {field: 'day_num', align: "center", width: '10%', title: '总天数',search:false},
                    {field: 'day_jf', align: "center", width: '10%', title: '每日领取',search:false},
                    {field: 'now_day', align: "center", width: '10%', title: '已领天数',search:false},
                    {field: 'now_jf', align: "center", width: '10%', title: '已领积分',search:false},
                    { fixed: 'right',align: 'center',width: '20%', title: '操作',toolbar: '#barTool' }
                ]
            ],
            page: {}
        });
        yznTable.bindevent();
        // selectElement = document.getElementById('c-province');
        // selectElement.setAttribute("lay-filter", "c-province");
        // form1();
        selectElement2 = document.getElementById('searchFieldset_currentTable');
        selectElement2.classList.remove("layui-hide");
        var element = document.getElementById('layui-input-search');
        element.parentNode.removeChild(element);

    });

    function form1() {
        layui.use('form', function () {
            var form = layui.form;
            form.on('select(c-province)', function (data) {
                console.log(data.value);
                $.ajax({
                    type: "POST",//规定传输方式
                    url: "{:url('getc_cate')}",//提交URL
                    data: {'id': data.value},//提交的数据
                    success: function (result) {
                        if (result.code == 200) {
                            $("#c-city").empty();
                            var str = "<option value>- 全部 -</option>";
                            $.each(result.data, function (i, val) {
                                str += '<option value=' + val.id + '>' + val.name + '</option>'
                            });
                            $("#c-city").append(str);
                            layui.form.render('select');
                        }
                    },
                    error: function () {
                        alert("获取信息失败")
                    }
                });
            })
        });
    }


</script>
{/block}